home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / scheme / pcscheme / geneva / sources.exe / SOURCES / ASM / SPROPRTY.ASM < prev    next >
Encoding:
Assembly Source File  |  1992-11-18  |  6.5 KB  |  209 lines

  1. ;* SPROPRTY.ASM
  2. ;************************************************************************
  3. ;*                                    *
  4. ;*        PC Scheme/Geneva 4.00 Borland TASM code            *
  5. ;*                                    *
  6. ;* (c) 1985-1988 by Texas Instruments, Inc. See COPYRIGHT.TXT        *
  7. ;* (c) 1992 by L. Bartholdi & M. Vuilleumier, University of Geneva    *
  8. ;*                                    *
  9. ;*----------------------------------------------------------------------*
  10. ;*                                    *
  11. ;*            Property management                *
  12. ;*                                    *
  13. ;*----------------------------------------------------------------------*
  14. ;*                                    *
  15. ;* Created by: John Jensen        Date: 1985            *
  16. ;* Revision history:                            *
  17. ;* - 18 Jun 92:    Renaissance (Borland Compilers, ...)            *
  18. ;*                                    *
  19. ;*                    ``In nomine omnipotentii dei''    *
  20. ;************************************************************************
  21. IDEAL
  22. %PAGESIZE    60, 132
  23. MODEL    medium
  24. LOCALS    @@
  25.  
  26.     INCLUDE    "scheme.ash"
  27.  
  28. CODESEG
  29. ;************************************************************************
  30. ;*        Search for Property in Property List            *
  31. ;*                                    *
  32. ;* Calling Sequence:    found? = prop_search(list,prop);        *
  33. ;*                                    *
  34. ;* Input Parameters:    list - the property list for a symbol.        *
  35. ;*            prop - the property for which to search.    *
  36. ;*                                    *
  37. ;* Output Parameters:    found? - if the property was found in the list,    *
  38. ;*            found?=1; else found?=0.            *
  39. ;*            list - a pointer to the property/value pair    *
  40. ;*            for the specified property. If not found, NIL.    *
  41. ;*                                    *
  42. ;* Note: This routine is an assembly language version of the following    *
  43. ;* C source:                                *
  44. ;* prop_search(list, prop)                        *
  45. ;* int list[2],prop[2];                            *
  46. ;* {                                    *
  47. ;*    int search[2];    /* current search entry in list */        *
  48. ;*    int temp[2];        /* temporary "register" */        *
  49. ;*    ENTER(prop_search);                        *
  50. ;*                                    *
  51. ;*    mov_reg(search, list);                        *
  52. ;*    take_cdr(search);                        *
  53. ;*    while(search[rPAGE])                        *
  54. ;*    {                                *
  55. ;*        mov_reg(temp, search);                    *
  56. ;*        take_car(temp);                        *
  57. ;*        if (eq(temp,prop))                    *
  58. ;*        {                            *
  59. ;*            mov_reg(list, search);                *
  60. ;*            return(FOUND);                    *
  61. ;*        }                            *
  62. ;*    take_cddr(search);                        *
  63. ;*    } /* end:        while(search[rPAGE]) */            *
  64. ;*    return(NOT_FOUND);                        *
  65. ;* } /* end of function:        prop_search(list, prop) */    *
  66. ;************************************************************************
  67. PROC C    prop_search USES si di, @@list:word, @@prop:word
  68.     mov    bx, [@@prop]        ; Load up the property into cl:dx
  69.     mov    cl, [(REG bx).bpage]
  70.     mov    dx, [(REG bx).disp]
  71.     mov    si, [@@list]        ; Load up a pointer to the beginning of the property list
  72.     xor    bx, bx
  73.     mov    bl, [(REG si).bpage]
  74.     mov    di, [(REG si).disp]
  75.     jmp    @@start
  76. @@didntmatch:
  77.     mov    bl, [(LISTDEF es:di).cdr.page]
  78.     mov    di, [(LISTDEF es:di).cdr.disp]
  79. @@start:
  80.     cmp    bl, 0
  81.     je    @@notfound
  82.     cmp    [ptype+bx], LISTTYPE
  83.     jne    @@notfound
  84.     ldpage    es, bx
  85.     mov    bl, [(LISTDEF es:di).cdr.page]
  86.     mov    di, [(LISTDEF es:di).cdr.disp]
  87.     cmp    bl, 0            ; Test for valid list cell
  88.     je    @@notfound
  89.     cmp    [ptype+bx], LISTTYPE
  90.     jne    @@notfound
  91.     ldpage    es, bx
  92.     cmp    dx, [(LISTDEF es:di).car.disp]
  93.     jne    @@didntmatch
  94.     cmp    cl, [(LISTDEF es:di).car.page]
  95.     jne    @@didntmatch
  96.     mov    [(REG si).bpage], bl ; move pointer to property entry
  97.     mov    [(REG si).disp], di ; into the "list" operand register
  98.     mov    ax, 1            ; indicate property found
  99.     ret
  100. @@notfound:
  101.     xor    ax, ax            ; indicate no match found
  102.     ret
  103. ENDP    prop_search
  104.  
  105. ;************************************************************************
  106. ;*        Search for Symbol in Property List            *
  107. ;*                                    *
  108. ;* Calling Sequence:    sym_search(sym)                    *
  109. ;*                                    *
  110. ;* Input Parameters:    sym - a register containing a symbol who's    *
  111. ;*            property list is to be located.            *
  112. ;*                                    *
  113. ;* Output Parameters:    sym - the register is updated to point to the    *
  114. ;*            property list for the symbol. If no property    *
  115. ;*            list exists, it is set to NIL.            *
  116. ;*                                    *
  117. ;* Note: This routine is an assembly language version of the following    *
  118. ;* C source:                                *
  119. ;* sym_search(sym)                            *
  120. ;* int sym[2];                                *
  121. ;* {                                    *
  122. ;*    int hash_value;            /* symbol's hash value */    *
  123. ;*    int sym_save[2];        /* initial value of symbol argument */*
  124. ;*    int temp[2];            /* temporary "register" */    *
  125. ;*    ENTER(sym_search);                        *
  126. ;*                                    *
  127. ;*    if (ptype[CORRPAGE(sym[rPAGE])] == SYMBTYPE)            *
  128. ;*    {                                *
  129. ;*    /* save symbol's page and displacement for testing purposes */    *
  130. ;*        mov_reg(sym_save, sym);                    *
  131. ;*                                    *
  132. ;*        /* obtain hash chain to search */            *
  133. ;*        hash_value = sym_hash(sym);                *
  134. ;*        sym[rPAGE] = prop_page[hash_value];            *
  135. ;*        sym[rDISP] = prop_disp[hash_value];            *
  136. ;*                                    *
  137. ;*        while(sym[rPAGE])                    *
  138. ;*        {                            *
  139. ;*            mov_reg(temp, sym);                *
  140. ;*            take_caar(temp);                *
  141. ;*            if (eq(temp, sym_save))                *
  142. ;*            {                        *
  143. ;*    /* symbol found-- return pointer to symbol's property list */    *
  144. ;*                take_car(sym);                *
  145. ;*                break;                    *
  146. ;*            }                        *
  147. ;*            else                        *
  148. ;*            {                        *
  149. ;*                take_cdr(sym);                *
  150. ;*            }                        *
  151. ;*        } /* end:        while(sym[rPAGE]) */        *
  152. ;*    }                                *
  153. ;* } /* end of function:        sym_search(sym) */        *
  154. ;************************************************************************
  155. PROC C    sym_search USES si di, @@symbol:word
  156.     mov    si, [@@symbol]
  157.     mov    bx, [(REG si).page]
  158.     cmp    [ptype+bx], SYMBTYPE
  159.     je    @@continue
  160.     jmp    @@notfound
  161. @@continue:
  162.     mov    si, [(REG si).disp]
  163.     ldpage    es, bx
  164.     mov    cx, bx            ; copy the symbol into cl:dx
  165.     mov    dx, si
  166.     mov    bl, [(SYMDEF es:si).hashkey]
  167.     mov    di, bx            ; copy hash key into di and
  168.     shl    di, 1            ; multiply by two for word index
  169.     mov    bl, [prop_page+bx]    ; load property list header for this
  170.     mov    di, [prop_disp+di]    ; symbol's bucket
  171.     jmp    @@start
  172. @@nextreload:
  173.     mov    bx, ax
  174.     ldpage    es, bx
  175. @@next:
  176.     mov    bl, [(LISTDEF es:di).cdr.page] ; load pointer to next bucket entry
  177.     mov    di, [(LISTDEF es:di).cdr.disp]
  178. @@start:
  179.     cmp    bl, 0            ; end of bucket?
  180.     je    @@notfound
  181.     cmp    [ptype+bx], LISTTYPE
  182.     jne    @@notfound
  183.     ldpage    es, bx
  184.     mov    ax, bx            ; Save Bucket entry page number
  185.     mov    bl, [(LISTDEF es:di).car.page] ; Fetch prop. from the CAR field of the bucket entry
  186.     mov    si, [(LISTDEF es:di).car.disp]
  187.     cmp    bl, 0            ; no property list for this bucket entry?
  188.     je    @@next
  189.     cmp    [ptype+bx], LISTTYPE
  190.     jne    @@next
  191.     ldpage    es, bx
  192.     cmp    dx, [(LISTDEF es:si).car.disp]
  193.     jne    @@nextreload
  194.     cmp    cl, [(LISTDEF es:si).car.page]
  195.     jne    @@nextreload
  196.     mov    di, [@@symbol]
  197.     mov    [(REG di).bpage], bl ; store prop list pointer into reg
  198.     mov    [(REG di).disp], si
  199.     ret
  200. @@notfound:
  201.     xor    ax, ax        ; create a NIL pointer
  202.     mov    di, [@@symbol]
  203.     mov    [(REG di).bpage], al
  204.     mov    [(REG di).disp], ax
  205.     ret
  206. ENDP    sym_search
  207.  
  208.     END
  209.